home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / UPC12BS2.ZIP / TEST / TESTSCRT.C < prev    next >
C/C++ Source or Header  |  1992-11-22  |  5KB  |  145 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    s c r t e s t                                                   */
  3. /*                                                                    */
  4. /*    login Script test driver for UUPC/extended                      */
  5. /*                                                                    */
  6. /*    Copyright (c) Andrew H. Derbyshire                              */
  7. /*                                                                    */
  8. /*    May be distributed freely if original source and                */
  9. /*    documentation files are included.  Please direct all            */
  10. /*    questions on UUPC/extended to help@kew.com.                     */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*    You know it's a REAL bitch if I write a test driver for it.     */
  15. /*--------------------------------------------------------------------*/
  16.  
  17.  
  18. /*--------------------------------------------------------------------*/
  19. /*                        System include files                        */
  20. /*--------------------------------------------------------------------*/
  21.  
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. #include <stdarg.h>
  26. #include <assert.h>
  27. #include <conio.h>
  28.  
  29. /*--------------------------------------------------------------------*/
  30. /*                    UUPC/extended included files                    */
  31. /*--------------------------------------------------------------------*/
  32.  
  33. #include "lib.h"
  34. #include "hlib.h"
  35. #include "script.h"
  36.  
  37. void slowwrite( char *s, int len);
  38.  
  39. /*--------------------------------------------------------------------*/
  40. /*    m a i n                                                         */
  41. /*                                                                    */
  42. /*    Main program for driver                                         */
  43. /*--------------------------------------------------------------------*/
  44.  
  45. void main( int argc, char **argv)
  46. {
  47.    int result;
  48.    char **failure = NULL;
  49.  
  50.    assert( argc > 1 );
  51.    if (argc > 2)
  52.       failure = &argv[2];
  53.  
  54.    result = expectstr( argv[1], 30, failure );
  55.    printf("Result of operation is %d",result);
  56.    exit(0);
  57.  
  58. } /* main */
  59.  
  60. /*--------------------------------------------------------------------*/
  61. /*           Replacement for UUPC/extended logging function           */
  62. /*--------------------------------------------------------------------*/
  63.  
  64. #pragma argsused
  65.  
  66. void printmsg(int level, char *fmt, ...)
  67. {
  68.    va_list arg_ptr;
  69.  
  70.    va_start(arg_ptr,fmt);
  71.    vfprintf(stdout, fmt, arg_ptr);
  72.    putchar('\n');
  73. }
  74.  
  75. void bugout( const size_t lineno, const char *fname )
  76. {
  77.    printmsg(0,"Program aborting at line %d in file %s",
  78.               lineno, fname );
  79.    fcloseall();
  80.    exit(69);
  81. } /*bugout */
  82.  
  83. /*--------------------------------------------------------------------*/
  84. /*    s r e a d                                                       */
  85. /*                                                                    */
  86. /*    Fake serial port read                                           */
  87. /*--------------------------------------------------------------------*/
  88.  
  89. extern unsigned int sread(char *buffer,
  90.                           unsigned int wanted,
  91.                           unsigned int timeout)
  92. {
  93.    int c;
  94.    int needed = wanted;
  95.    printf("sread(%d,%d):",wanted,timeout);
  96.  
  97.    while(needed-- > 0)
  98.    {
  99.       c = getch();
  100.       if ( c == '.' )
  101.          return -1;
  102.       else
  103.          *buffer++ = c;
  104.    }
  105.  
  106.    putchar('\n');
  107.  
  108.    return wanted;
  109. }
  110.  
  111. int swrite(char *data, unsigned int len)
  112. {
  113.    int needed = len;
  114.    printf("swrite:");
  115.    while ( needed-- )
  116.       putchar( *data++ );
  117.    putchar('\n');
  118.    return len;
  119. }
  120.  
  121. void ssendbrk(unsigned int duration)
  122. {
  123.    printf("BREAK %d\n",duration);
  124. }
  125.  
  126. /*--------------------------------------------------------------------*/
  127. /*    s l o w w r i t e                                               */
  128. /*                                                                    */
  129. /*    Write characters to the serial port at a configurable           */
  130. /*    snail's pace.                                                   */
  131. /*--------------------------------------------------------------------*/
  132.  
  133. void slowwrite( char *s, int len)
  134. {
  135.    swrite( s , len );
  136. } /* slowwrite */
  137.  
  138. #pragma argsused
  139.  
  140. void SIOSpeed(BPS bps)
  141. {
  142.    printf("SIOSPEED\n");
  143.  
  144. } /*SIOSpeed*/
  145.